local skel = fk.CreateSkill {
  name = "lb_zero__gexian",
  tags = {Skill.Compulsory}
}

Fk:loadTranslationTable {
  ["lb_zero__gexian"] = "弋陷",
  [":lb_zero__gexian"] = "<b>锁定技</b>，每名角色限一次，当你对其他角色造成伤害后，直到其下回合开始前，其于回合外响应牌后须弃置两张手牌。",

  ["#lb_zero__gexian"] = "弃牌",
  ["@[player_string]lb_zero__gexian"] = "弋陷",

  ["$lb_zero__gexian1"] = "很快就结束。",
  ["$lb_zero__gexian2"] = "弱者，就等着被捕食吧。",
}

skel:addEffect(fk.Damage, {
  anim_type = "control",
  can_trigger = function (self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) 
    and player:getTableMark("@[player_string]lb_zero__gexian")[tostring(data.to.id)] == nil
  end,
  on_use = function (self, event, target, player, data)
    local list = player:getTableMark("@[player_string]lb_zero__gexian")
    list[tostring(data.to.id)] = "#lb_zero__gexian"
    player.room:setPlayerMark(player, "@[player_string]lb_zero__gexian", list)
  end,
})

skel:addEffect(fk.TurnStart, {
  can_refresh = function (self, event, target, player, data)
    return player:hasSkill(skel.name, true) and player:getTableMark("@[player_string]lb_zero__gexian")[tostring(target.id)] ~= nil
  end,
  on_refresh = function (self, event, target, player, data)
    local list = player:getTableMark("@[player_string]lb_zero__gexian")
    list[tostring(target.id)] = ""
    player.room:setPlayerMark(player, "@[player_string]lb_zero__gexian", list)
  end,
})

local gexian_spec = {
  is_delay_effect = true,
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and player:getTableMark("@[player_string]lb_zero__gexian")[tostring(target.id)] == "#lb_zero__gexian"
    and data.responseToEvent and data.responseToEvent.from and not target:isKongcheng()
    and target ~= player.room:getCurrent()
  end,
  on_cost = function(self, event, target, player, data)
    local cards = player.room:askToDiscard(target, {
      min_num = 2,
      max_num = 2,
      skill_name = skel.name,
      skip = true,
      cancelable = false,
      include_equip = false,
    })
    if #cards > 0 then
      event:setCostData(self, { cards = cards })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    player.room:throwCard(event:getCostData(self).cards, skel.name, target)
  end,
}

skel:addEffect(fk.CardUseFinished, gexian_spec)
skel:addEffect(fk.CardRespondFinished, gexian_spec)

return skel
